package com.atguigu.tingshu.user.api;

import com.atguigu.tingshu.common.anno.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.user.service.UserListenProcessService;
import com.atguigu.tingshu.vo.user.LastUserListenPlayVo;
import com.atguigu.tingshu.vo.user.UserListenProcessVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@Tag(name = "用户声音播放进度管理接口")
@RestController
@RequestMapping("api/user/userListenProcess")
@SuppressWarnings({"unchecked", "rawtypes"})
public class UserListenProcessApiController {

	@Autowired
	private UserListenProcessService userListenProcessService;

	@GuiguLogin
	@PostMapping(value = "/updateListenProcess")
	public Result  updateListenProcess(@RequestBody UserListenProcessVo userListenProcessVo) {
		userListenProcessService.userListenProcessVo(userListenProcessVo) ;
		return Result.ok();
	}

	@GuiguLogin
	@GetMapping(value = "/getTrackBreakSecond/{trackId}")
	public Result<BigDecimal>  getTrackBreakSecond(@PathVariable(value = "trackId") Long trackId){

		BigDecimal breakSecond = userListenProcessService.getTrackBreakSecond(trackId);
		return Result.ok(breakSecond) ;
	}

	//获取用户最近听取的专辑
	@GuiguLogin
	@GetMapping(value = "/getLatelyTrack")
	public Result<LastUserListenPlayVo> getLatelyTrack() {
		LastUserListenPlayVo lastUserListenPlayVo = userListenProcessService.getLatelyTrack() ;
		return Result.ok(lastUserListenPlayVo) ;
	}

}

